import java.util.Scanner;

public class test12 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        // 先找到数字的两边
        int left,right;
        for (int i = 0;;i++){
            left  = getResult(i);
            right = getResult(i+1);
            if(left<=n&&right>=n)
                break;
        }
        left = Math.min((n-left), (right-n));
        System.out.println(left);
    }
    public static int getResult(int val){
        if(val == 0)
            return 0;
        else if (val == 1)
            return 1;
        else{
            return getResult(val-1)+getResult(val-2);
        }
    }
}
